-
Notifications
You must be signed in to change notification settings - Fork 295
Add Atom version to the printed version information #745
Conversation
2322ed5
to
ea2fb36
Compare
I rebased on top of 8fb7456 today. Please let me know if there is anything on my end that I am able to help with. [edit for grammar] |
src/apm-cli.coffee
Outdated
|
||
getAtomVersion = (callback) -> | ||
config.getResourcePath (resourcePath) -> | ||
# workaround if app.asar does not exist. see: https://github.com/atom/atom/issues/6604 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is 6604 still a problem? There was only one report of it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I ran into it while testing. For whatever reason app.asar
does not exist on my machine.
~ ❯❯❯ sw_vers
ProductName: Mac OS X
ProductVersion: 10.11.6
BuildVersion: 15G1611
~/D/p/apm ❯❯❯ ls /Applications/Atom.app/Contents/Resources/ atom-version
LICENSE.md bg.lproj de.lproj en_GB.lproj fi.lproj he.lproj it.lproj lv.lproj nl.lproj ru.lproj sw.lproj uk.lproj
am.lproj bn.lproj el.lproj es.lproj fil.lproj hi.lproj ja.lproj ml.lproj pl.lproj sk.lproj ta.lproj vi.lproj
app ca.lproj electron.asar es_419.lproj file.icns hr.lproj kn.lproj mr.lproj pt_BR.lproj sl.lproj te.lproj zh_CN.lproj
ar.lproj cs.lproj electron.icns et.lproj fr.lproj hu.lproj ko.lproj ms.lproj pt_PT.lproj sr.lproj th.lproj zh_TW.lproj
atom.icns da.lproj en.lproj fa.lproj gu.lproj id.lproj lt.lproj nb.lproj ro.lproj sv.lproj tr.lproj
~/D/p/apm ❯❯❯ apm --version atom-version
apm 1.18.4
npm 3.10.10
node 6.9.5 x64
python 2.7.10
git 2.14.2
~/D/p/apm ❯❯❯ atom --version atom-version
Atom : 1.20.1
Electron: 1.6.9
Chrome : 56.0.2924.87
Node : 7.4.0
src/apm-cli.coffee
Outdated
if not fs.existsSync(resourcePath) | ||
resourcePath = resourcePath.replace('.asar', path.sep) | ||
try | ||
{version} = require(path.join(resourcePath, 'package.json')) ? {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would probably be better to return unknown
rather than an empty object.
ea2fb36
to
99bec86
Compare
Based on @50Wliu's suggestion. See https://github.com/atom/apm/pull/745\#discussion_r140909097
99bec86
to
4abb7ce
Compare
4abb7ce
to
53cccbc
Compare
53cccbc
to
90b79dd
Compare
@50Wliu It will now return |
spec/apm-cli-spec.coffee
Outdated
path = require 'path' | ||
temp = require 'temp' | ||
fs = require 'fs' | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove empty newline
90b79dd
to
ad5cbde
Compare
@50Wliu I removed the empty newline. |
src/apm-cli.coffee
Outdated
apm: apmVersion | ||
npm: npmVersion | ||
node: nodeVersion | ||
atomVersion: atomVersion |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason this is atomVersion
and not just atom
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Other than copy 🍝 , no. Fixed in ffdb043
src/apm-cli.coffee
Outdated
getAtomVersion = (callback) -> | ||
config.getResourcePath (resourcePath) -> | ||
unknownVersion = 'unknown' | ||
# workaround if app.asar does not exist. see: https://github.com/atom/atom/issues/6604 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We haven't seen any reports of 6604 in a while. Is this needed? Did you run into it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. #745 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whoops! Totally forgot I commented about it before 😊
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems Atom 1.21 added back app.asar
, see: #738 (comment)
For users who have Atom 1.20 and any other versions which do not use app.asar
the workaround check seems to be needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, good to know. Since apm is bundled with Atom and can't be installed manually, I think it's safe to remove this check since it'll be bundled with at least Atom 1.23 at this point.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. See e397021
testAtomVersion = '0.0.0' | ||
tempAtomResourcePath = temp.mkdirSync('apm-resource-dir-') | ||
fs.writeFileSync(path.join(tempAtomResourcePath, 'package.json'), JSON.stringify(version: testAtomVersion)) | ||
process.env.ATOM_RESOURCE_PATH = tempAtomResourcePath |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is reset at the end of the test, correct? If not it needs to be.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When you say this, do you mean process.env.ATOM_RESOURCE_PATH
?
If so, I am basing this test logic off of other -spec
examples. I do not see where it is reset. Is there an example of how to reset it?
Lines 38 to 47 in 5cf83aa
resourcePath = temp.mkdirSync('apm-resource-path-') | |
atomPackages = | |
'test-module': | |
metadata: | |
name: 'test-module' | |
version: '1.0.0' | |
fs.writeFileSync(path.join(resourcePath, 'package.json'), JSON.stringify(_atomPackages: atomPackages)) | |
process.env.ATOM_RESOURCE_PATH = resourcePath | |
atomHome = temp.mkdirSync('apm-home-dir-') | |
process.env.ATOM_HOME = atomHome |
Lines 24 to 25 in c9f0210
resourcePath = temp.mkdirSync('atom-resource-path-') | |
process.env.ATOM_RESOURCE_PATH = resourcePath |
Lines 143 to 144 in d55f94a
it "logs an error when the installed location of Atom cannot be found", -> | |
process.env.ATOM_RESOURCE_PATH = '/tmp/atom/is/not/installed/here' |
Lines 19 to 22 in d399d88
atomHome = temp.mkdirSync('apm-home-dir-') | |
process.env.ATOM_HOME = atomHome | |
process.env.ATOM_API_URL = "http://localhost:3000/api" | |
process.env.ATOM_RESOURCE_PATH = temp.mkdirSync('atom-resource-path-') |
Lines 30 to 35 in b758628
atomHome = temp.mkdirSync('apm-home-dir-') | |
process.env.ATOM_HOME = atomHome | |
process.env.ATOM_ELECTRON_URL = "http://localhost:3000/node" | |
process.env.ATOM_PACKAGES_URL = "http://localhost:3000/packages" | |
process.env.ATOM_ELECTRON_VERSION = 'v0.10.3' | |
process.env.ATOM_RESOURCE_PATH = temp.mkdirSync('atom-resource-path-') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah ok, it is reset. You linked to it in the first code snippet.
Line 45 in 5cf83aa
process.env.ATOM_RESOURCE_PATH = resourcePath |
👍 |
Alternate Designs
Using
spawn
ingetPythonVersion
, similar to @arabelle's approach. See: https://github.com/arabelle/apm/blob/59f70d50571090fe205bf6b03c03f0c86398f5f4/src/apm-cli.coffee#L132-L143I did not want to spawn a new process and parse it's output since I have access to Atom's
package.json
Benefits
Closes #382
Possible Drawbacks
There is a workaround due to an issue on macOS I ran into while testing. Ideally, the workaround that checks withRemoved workaround see #745 (comment)getResourcePath
is not used.Applicable Issues
#453, #473
, and atom/atom#6604/cc @jebschiefer and @arabelle who worked on original PRs